package homework.homework_7.Student;

/**
 * @author 朱
 * @date 201904018:43
 */

import java.util.ArrayList;

/**
 * 2、去除集合中自定义对象的重复值(对象的成员变量值都相同)
 * // 创建学生对象
 * 		Student s1 = new Student("林青霞", 27);
 * 		Student s2 = new Student("林志玲", 40);
 * 		Student s3 = new Student("凤姐", 35);
 * 		Student s4 = new Student("芙蓉姐姐", 18);
 * 		Student s5 = new Student("翠花", 16);
 * 		Student s6 = new Student("林青霞", 27);
 * 		Student s7 = new Student("林青霞", 18);
 * // 集合对象中添加这些学生对象
 * // 去除集合中这些重复值（假设对象中的成员变量值都相同，则认为该这些对象是重复）
 */
public class StudentTest {
    public static void main(String[] args) {
        Student s1 = new Student("林青霞", 27);
 	    Student s2 = new Student("林志玲", 40);
  		Student s3 = new Student("凤姐", 35);
 		Student s4 = new Student("芙蓉姐姐", 18);
 		Student s5 = new Student("翠花", 16);
 		Student s6 = new Student("林青霞", 27);
 		Student s7 = new Student("林青霞", 18);
        ArrayList<Student> arrayList=new ArrayList<Student>();
        arrayList.add(s1);
        arrayList.add(s2);
        arrayList.add(s3);
        arrayList.add(s4);
        arrayList.add(s5);
        arrayList.add(s6);
        arrayList.add(s7);
//        for (int i = 0; i <arrayList.size() ; i++) {
//            for (int j = i+1; j <arrayList.size() ; j++) {
//                if (arrayList.get(i).getName().equals(arrayList.get(j).getName())&&arrayList.get(i).getAge()==arrayList.get(j).getAge()){
//                    arrayList.remove(j);
//                    j--;
//                }
//            }
//        }
        for (int i = 0; i <arrayList.size() ; i++) {
            System.out.println(arrayList.get(i));
        }
    }

}
